package com.xiyou.luckdraw.web;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

/**
 * @ClassName: LuckdrawApplication
 * @Description: Luckdraw启动类
 * @author: limingxing
 * @Date: 2019-10-07 19:38
 */
@SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
@ComponentScan(basePackages = "com.xiyou.luckdraw")
//@EnableAutoConfiguration(exclude = {MultipartAutoConfiguration.class})
public class LuckdrawApplication {

    public static void main(String[] args) {
        SpringApplication.run(LuckdrawApplication.class, args);
        System.out.println("*****************OK*****************");
    }

    @Bean(name = "multipartResolver")
    public MultipartResolver multipartResolver(){
        CommonsMultipartResolver resolver = new CommonsMultipartResolver();
        resolver.setDefaultEncoding("UTF-8");
        resolver.setResolveLazily(true); //resolveLazily属性启用是为了推迟文件解析，以在在UploadAction中捕获文件大小异常
        resolver.setMaxInMemorySize(4096);
        resolver.setMaxUploadSize(5*1024*1024 );//上传文件大小 5M 5*1024*1024
        return resolver;
    }
}
